package org.lyj.samples;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class EventBusReceiverVerticle extends AbstractVerticle {

    private static final Logger logger = LoggerFactory.getLogger(EventBusReceiverVerticle.class);

    private String name;

    public EventBusReceiverVerticle(String name) {
        this.name = name;
    }

    @Override
    public void start(Future<Void> startFuture) throws Exception {
        vertx.eventBus().consumer("anAddress", message -> {
            logger.info(this.name + " received message: " + message.body());
            message.reply("receive");
        });
        logger.info("receiver start ...");
    }
}
